package com.peas.platform.framework.mybatisplus.config;

import cn.hutool.core.lang.UUID;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.peas.platform.common.core.constant.Constants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class CustomIdGenerator implements IdentifierGenerator {

    @Override
    public Number nextId(Object po) {
        Long id = Constants.snowflake.nextId();
        log.debug("CustomIdGenerator:" + id);
        return id;
    }

    @Override
    public String nextUUID(Object po) {
        String id = UUID.fastUUID().toString(true);
        log.debug("CustomIdGenerator:" + id);
        return id;
    }

}
